package practice3;

import java.util.Scanner;

public class P8692 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextInt();
        sc.close();
        long ans=0;
        long e=1000000007;      //模的数
        for (int i = 1; i < n; i++) {       //i为边长
            ans=(ans+i*(n-i)*(n-i))%e;         //边长为i的平放正方形共有(n-i)*(n-i)个，每个正方形其内部有i-1个斜放的正方形,算上本身共i个
        }                                       //即边长为i的正方形共有(n-i)*(n-i)*i个
        System.out.println(ans);

    }
}
